﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="TireSetList.aspx.cs" Inherits="TireService.Web.View.CustomerView.TireSetList" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>

<%@ Register src="../../UserControls/ucEditTireSet.ascx" tagname="ucEditTireSet" tagprefix="uc1" %>
<%@ Register src="../../UserControls/ucEditTireSetPattern.ascx" tagname="ucEditTireSetPattern" tagprefix="uc2" %>
<%@ Register src="../../UserControls/ucTireSetPatternGraph.ascx" tagname="ucTireSetPatternGraph" tagprefix="uc3" %>
<%@ Register src="../../UserControls/ucTireSetLog.ascx" tagname="ucTireSetLog" tagprefix="uc4" %>
<%@ Register src="../../UserControls/ucMoveTireSet.ascx" tagname="ucMoveTireSet" tagprefix="uc5" %>
<%@ Register src="../../UserControls/ucCreateTask.ascx" tagname="ucCreateTask" tagprefix="uc6" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="imgTireSet" alt="" src="~/Images/Medium/wheel.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblTireSetListHeader" runat="server" Text="Hjulsæt"></asp:Label></h3>
            </td>
            <td>
                <asp:UpdatePanel ID="upMessage" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <table border="0" cellspacing="0" cellpadding="5">
                            <tr>
                                <td>
                                    <div style="font-family: Tahoma; font-size: 9pt; font-weight: normal; color: #f15e34">
                                        &nbsp;<asp:Literal ID="lMessage" runat="server"></asp:Literal>
                                    </div>
                                </td>
                            </tr>
                        </table>          
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>
    <hr />                
    
    <!-- Javascript of action dropdown list -->
    <script language="javascript" type="text/javascript">

        // Function that handles actions selected in dropdown list
        function ActionClicked() {

            // Get selected action from dropdownlist
            var id = ddlAction.GetValue();

            if (id != null && id != 0) {

                //                // Change status on selected cars
                //                if (id == 1) {
                //                    // Show popup for status change
                //                    pcChangeStatus.Show();
                //                }
            }
            else {
                alert('Ingen handling valgt');
            }
        }

        // -- Implementation script for Edit TireSet --
        // Functions for initiating edit tireset modalpopup - usercontrol
        function ShowEditTireSetModalPopup(element, key) {
            callbackEditTireSetPanel.SetContentHtml("");
            pcEditTireSet.ShowAtElement(element);
            callbackEditTireSetPanel.PerformCallback(key);
            EditTireSetKeyValue = key;
        }

        // Function from usercontrol when edit tireset completed
        function EditTireSetRefreshParent() {
            gvTireSet.PerformCallback();
        }

        // -- Implementation script for TireSet Pattern UserControl --
        // Functions for edit tireset pattern modalpopup
        function ShowEditTireSetPatternModalPopup(element, key) {
            callbackEditTireSetPatternPanel.SetContentHtml("");
            pcEditTireSetPattern.ShowAtElement(element);
            callbackEditTireSetPatternPanel.PerformCallback(key);
            EditTireSetPatternKeyValue = key;
        }

        function EditTireSetPatternRefreshParent() {
            gvTireSet.PerformCallback();
        }

        // -- Implementation script for TireSet Pattern Graph UserControl --
        // Functions for edit tireset pattern modalpopup
        function ShowTireSetGraphPatternModalPopup(element, key) {
            callbackTireSetPatternGraphPanel.SetContentHtml("");
            pcTireSetPatternGraph.ShowAtElement(element);
            callbackTireSetPatternGraphPanel.PerformCallback(key);
            TireSetPatternGraphKeyValue = key;
        }

        // -- Implementation script for TireSet Log UserControl --
        // Functions for tireset log modalpopup
        function ShowTireSetLogModalPopup(element, key) {
            callbackTireSetLogPanel.SetContentHtml("");
            pcTireSetLog.ShowAtElement(element);
            callbackTireSetLogPanel.PerformCallback(key);
            TireSetLogKeyValue = key;
        }

        // -- Implementation script for TireSet Move UserControl --
        // Functions for tireset move modalpopup
        function ShowMoveTireSetModalPopup(element, key) {
            callbackMoveTireSetPanel.SetContentHtml("");
            pcMoveTireSet.ShowAtElement(element);
            callbackMoveTireSetPanel.PerformCallback('NoAction' + '|' + key);
            MoveTireSetKeyValue = key;
        }

        function MoveCargoRoomRefreshParent() {
            gvTireSet.PerformCallback();
        }

        function MoveContainerRefreshParent() {
            gvTireSet.PerformCallback();
        }

        // -- Implementation script for Create Task UserControl --
        // Functions for create task modalpopup
        function ShowCreateTaskModalPopup(element, key, key2, key3) {
            callbackCreateTaskPanel.SetContentHtml("");
            pcCreateTask.ShowAtElement(element);
            callbackCreateTaskPanel.PerformCallback('NoAction' + '|' + key + '|' + key2 + '|' + key3);
            CreateTaskCustomerIdKeyValue = key;
        }

    </script>        

    <table border="0" cellspacing="0" cellpadding="5" width="100%">
        <tr>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlAction" ClientInstanceName="ddlAction" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="true" Value="0" Text="-- Handling --" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnSubmitAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False" Width="75px">
                    <ClientSideEvents Click="function(s, e) { ActionClicked(); }" />
                </dxe:ASPxButton>
            </td>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlExport" ClientInstanceName="ddlExport" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="True" Value="0" Text="Export pdf" />
                        <dxe:ListEditItem Value="1" Text="Export xls" />
                        <dxe:ListEditItem Value="2" Text="Export csv" />
                        <dxe:ListEditItem Value="3" Text="Export rtf" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnExport" runat="server" Text="Exporter" OnClick="btnExport_Click" Width="75px" >
                </dxe:ASPxButton>
            </td>
            <td align="right">
                <asp:Label ID="lblView" runat="server" Text="Visning"></asp:Label>
                <asp:DropDownList ID="ddlView" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddlView_SelectedIndexChanged">
                    <asp:ListItem Value="0">Ingen gruppering</asp:ListItem>
                    <asp:ListItem Value="1">Grupper efter Mærke</asp:ListItem>
                </asp:DropDownList>
                &nbsp;
                <asp:Label ID="lblPageSize" runat="server" Text="Antal linjer pr side"></asp:Label>
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true">
                    <asp:ListItem Value="10">10</asp:ListItem>
                    <asp:ListItem Value="25">25</asp:ListItem>
                    <asp:ListItem Value="50">50</asp:ListItem>
                    <asp:ListItem Value="100">100</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    <hr />          
                
    <dxwgv:ASPxGridView ID="gvTireSet" runat="server" ClientInstanceName="gvTireSet" Width="100%" 
        KeyFieldName="TireSetId" AutoGenerateColumns="False" EnableCallBacks="True">
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <Settings ShowHeaderFilterButton="true" ShowGroupPanel="false" ShowFilterRow="True" />
        <SettingsPager AlwaysShowPager="True" PageSize="20" Position="TopAndBottom">
            <Summary 
                AllPagesText="Sider: {0} - {1} ({2} hjulsæt)" 
                Text="Side {0} af {1} ({2} hjulsæt)" />
        </SettingsPager>
        <SettingsText ConfirmDelete="Vil du slette dette hjulsæt?" />
        <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
        <Columns>
            <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                    <HeaderTemplate>
                        <input type="checkbox" onclick="gvTireSet.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                    </HeaderTemplate>
                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                        HorizontalAlign="Center">
                    <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                    </HeaderStyle>
            </dxwgv:GridViewCommandColumn>
            <dxwgv:GridViewDataColumn Caption="Rediger" Width="106px" VisibleIndex="1">
                <DataItemTemplate>
                    <a href="javascript:void(0);" onclick="ShowEditTireSetModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/wheel.png" id="imgWheel" runat="server" alt="Rediger dæk oplysninger" /></a> <a href="javascript:void(0);" onclick="ShowEditTireSetPatternModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/measure.png" runat="server" id="imgTirePattern" alt="Rediger dækmønster" /></a> <a href="javascript:void(0);" onclick="ShowTireSetGraphPatternModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/line-chart.png" runat="server" id="imgTirePatternGraph" alt="Vis dækmønster historik" /></a> <a href="javascript:void(0);" onclick="ShowTireSetLogModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/history.png" runat="server" id="img1" alt="Vis historik" /></a> <a href="javascript:void(0);" onclick="ShowMoveTireSetModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/box_out.png" runat="server" id="img2" alt="Flyt hjulsæt" /></a> <a href="javascript:void(0);" onclick="ShowCreateTaskModalPopup(this, '<%# Eval("CustomerId") %>', '<%# Eval("CarId") %>', '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/contract.png" id="img3" runat="server" alt="Opret opgave" /></a>
                </DataItemTemplate>
            </dxwgv:GridViewDataColumn>

            <dxwgv:GridViewDataColumn FieldName="ContainerNumber" VisibleIndex="1" Caption="Lager">
            </dxwgv:GridViewDataColumn>
            <%--<dxwgv:GridViewDataColumn FieldName="CargoRoomNumber" VisibleIndex="2" Caption="Lagerplads">
            </dxwgv:GridViewDataColumn>--%>
            <dxwgv:GridViewDataHyperLinkColumn FieldName="ContainerCargoRoomId" VisibleIndex="2" Caption="Lagerplads">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/ResourceView/ContainerList.aspx?ContainerCargoRoomId={0}" TextField="CargoRoomNumber" >
                </PropertiesHyperLinkEdit>
            </dxwgv:GridViewDataHyperLinkColumn>
            <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="2" Caption="Reg.nr">
            </dxwgv:GridViewDataColumn>
            <%--<dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="2" Caption="Dæksæt ID">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomer.aspx?CustomerId={0}#tireset" TextField="TireSetId">
                </PropertiesHyperLinkEdit>
            </dxwgv:GridViewDataHyperLinkColumn>--%>
            <dxwgv:GridViewDataColumn FieldName="TireSetStatusId" Visible="false" VisibleIndex="5" Caption="TireSetStatusId">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataTextColumn FieldName="TireSetStatusDescription" VisibleIndex="5" Caption="Status">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataColumn FieldName="TireTypeId" Visible="false" VisibleIndex="5" Caption="TireTypeId">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataTextColumn FieldName="TireTypeDescription" VisibleIndex="5" Caption="Dæktype">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataColumn FieldName="TireBrandId" Visible="false" VisibleIndex="5" Caption="TireBrandId">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataTextColumn FieldName="TireBrandDescription" VisibleIndex="5" Caption="Mærke">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataColumn FieldName="TireBrandNote" VisibleIndex="5" Caption="Model variant">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataTextColumn FieldName="Width" VisibleIndex="6" Caption="Bredde">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataColumn FieldName="Height" VisibleIndex="7" Caption="Højde">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="Size" VisibleIndex="8" Caption="Fælgstr.">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="LeftFrontTirePattern" VisibleIndex="8" Caption="VF">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="RightFrontTirePattern" VisibleIndex="8" Caption="HF">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="LeftRearTirePattern" VisibleIndex="8" Caption="VB">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="RightRearTirePattern" VisibleIndex="8" Caption="HB">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="NeedBalancing" VisibleIndex="15" Caption="Skal afbal.">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="LastBalancingDate" VisibleIndex="15" Caption="Sidste afbal.">
            </dxwgv:GridViewDataColumn>
            
        </Columns>                                            
    </dxwgv:ASPxGridView>
                
    <dxwgv:ASPxGridViewExporter ID="gvExport" runat="server" GridViewID="gvTireSet">
    </dxwgv:ASPxGridViewExporter>
    
    <uc1:ucEditTireSet ID="ucEditTireSet" runat="server" />
    <uc2:ucEditTireSetPattern ID="ucEditTireSetPattern" runat="server" />
    <uc3:ucTireSetPatternGraph ID="ucTireSetPatternGraph" runat="server" />
    <uc4:ucTireSetLog ID="ucTireSetLog" runat="server" />
    <uc5:ucMoveTireSet ID="ucMoveTireSet" runat="server" />
    <uc6:ucCreateTask ID="ucCreateTask" runat="server" />


    <%--<!-- Modalpopup: Edit tireset -->
    <dx:ASPxPopupControl ID="pcEditTireSet" Modal="true" runat="server" Height="1px" AutoUpdatePosition="true"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
        AllowDragging="True" ClientInstanceName="pcEditTireSet" Left="100" Top="100"
        CloseAction="CloseButton" Width="175px" HeaderText="Rediger hjulsæt">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxCallbackPanel ID="callbackPanel" ClientInstanceName="callbackPanel" runat="server"
                    Width="320px" Height="100px" OnCallback="callbackPanel_Callback" RenderMode="Table">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <uc1:ucEditTireSet ID="ucEditTireSet1" runat="server" OnTireSetEditCancelled="ucEditTireSet1_TireSetEditCancelled" OnTireSetSaved="ucEditTireSet1_TireSetSaved" />
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxCallbackPanel>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ClientSideEvents Shown="EditTireSetPopup_Shown" />
    </dx:ASPxPopupControl>--%>

</asp:Content>
